import {createStore,applyMiddleware ,compose} from 'redux';
import rootReducer from './reducers'
import history from '@/history';
import { routerMiddleware } from 'connected-react-router';
import logger from 'redux-logger'
import thunk from 'redux-thunk'
import promise from 'redux-promise-middleware'
import { persistStore, persistReducer } from 'redux-persist'
// 默认存储在 localStorage
import storage from 'redux-persist/lib/storage'
import storageSession from 'redux-persist/lib/storage/session'

const persistConfig = {
    key: 'root',
    storage:storageSession,
}
const persistedReducer = persistReducer(persistConfig, rootReducer)


const store=createStore(persistedReducer,applyMiddleware(
    thunk,
    promise,
    routerMiddleware(history),
))

const persistor =persistStore(store);

window.store=store;
window.persistor=persistor;

export  {
    store,
    persistor
};


export default store;